import { translateByCode } from '@/lib/getTransData.js';
import validator from '../index.js';
import { FormLoginVO, MsgLoginVO } from '@/lib/form/login.js';
// 账号、密码提交
export class FormLoginVO_Rules extends FormLoginVO {
  constructor() {
    super();
    this.userNameOrEmailAddress = [
      {
        required: true,
        message: translateByCode('rules.requiredUserName'),
        trigger: 'blur'
      }
    ];
    this.password = [
      {
        required: true,
        message: translateByCode('rules.requiredPassword'),
        trigger: 'blur'
      }
    ];
  }
}
// 账号、手机验证码提交
export class MsgLoginVO_Rules extends MsgLoginVO {
  constructor() {
    super();
    this.userNameOrEmailAddress = [
      validator.required(translateByCode('rules.requiredUserName')),
      {
        validator (rule, value, callback) {
          callback(validator.checkPhone(value, translateByCode('rules.validTelephone')));
        },
        trigger: 'blur'
      }
    ];
    this.verifyCode = [
      {
        required: true,
        message: translateByCode('rules.verifyCode'),
        trigger: 'blur'
      },
      {
        min: 4,
        max: 4,
        message: translateByCode('rules.validVerifyCode'),
        trigger: 'blur'
      }
    ];
  }
}
